/*
 * Copyright (c) gitee.com/jiandong001.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import hilog from '@ohos.hilog';
import nativeReactHarmony from 'libreactharmony.so'

export class SoLoader {
  private static TAG: string = "SoLoader"

  //  private static reactHarmony: any
  //TODO load napi related library
  public static loadLibrary(shortName: string) {
    //      import("libreactharmony.so").then((value) => {
    //        // `a` is imported and can be used here
    //        SoLoader.reactHarmony = value
    //      });
  }

  public static init(nativeExopackage: boolean): void {
    hilog.info(0x0000, SoLoader.TAG, '%{public}s', "init");
    //    try {
    //        init(context, nativeExopackage ? 1 : 0, (SoFileLoader)null, DEFAULT_DENY_LIST);
    //    } catch (IOException var3) {
    //        throw new RuntimeException(var3);
    //    }
  }

  public static napiRunScriptFromFilePath(filePath: string) {
    hilog.info(0x0000, SoLoader.TAG, "napiRunScriptFromFilePath: " + filePath);
    hilog.info(0x0000, SoLoader.TAG, "add " + nativeReactHarmony.add(1,2))
    nativeReactHarmony.napiRunScriptFromFilePath(filePath);
  }

  public static napiRunScriptFromArrayBuffer(buffer: ArrayBuffer) {
    hilog.info(0x0000, SoLoader.TAG, "napiRunScriptFromBuffer");
    hilog.info(0x0000, SoLoader.TAG, "add " + nativeReactHarmony.add(1,2))
    nativeReactHarmony.napiRunScriptFromArrayBuffer(buffer);
  }
}
